//
//  CollectTableViewCell.m
//  quanminzhekou
//
//  Created by zxl on 15/1/15.
//  Copyright (c) 2015年 zhongqinglongtu. All rights reserved.
//

#import "CollectTableViewCell.h"

@interface CollectTableViewCell ()
@property (nonatomic, weak) IBOutlet UIView* markView;
@property (nonatomic, weak) IBOutlet UIView* bgView;
@property (nonatomic, weak) IBOutlet UIImageView* selectImg;
@property (nonatomic, weak) IBOutlet UIImageView* outImg;
@property (nonatomic, weak) IBOutlet UIImageView* upComingImg;
@end

@implementation CollectTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
}

- (void)setType:(CollectTableViewCellType)type {
    _type = type;
    switch (type) {
        case CollectTableViewCellTypeNone:
            self.markView.hidden = YES;
            self.bgView.hidden = YES;
            self.selectImg.hidden = YES;
            self.outImg.hidden = YES;
            self.upComingImg.hidden = YES;
            self.isCanSwip = YES;
            break;
            
        case CollectTableViewCellTypeIsReadyDelete:
            self.markView.hidden = NO;
            self.bgView.hidden = NO;
            self.selectImg.hidden = NO;
            self.outImg.hidden = self.outImg.hidden;
            self.upComingImg.hidden = self.upComingImg.hidden;
            self.isCanSwip = NO;
            break;
            
        case CollectTableViewCellTypeGoodsIsOut:
            self.markView.hidden = NO;
            self.bgView.hidden = NO;
            self.selectImg.hidden = YES;
            self.outImg.hidden = NO;
            self.upComingImg.hidden = YES;
            self.isCanSwip = YES;
            break;
            
        case CollectTableViewCellTypeGoodsUpComing:
            self.markView.hidden = NO;
            self.bgView.hidden = NO;
            self.selectImg.hidden = YES;
            self.outImg.hidden = YES;
            self.upComingImg.hidden = NO;
            self.isCanSwip = YES;
            break;
            
        default:
            break;
    }
}

#pragma mark - super 
- (void)layoutSubviewDataWithViewModel:(CommonCellViewModel *)viewModel {
    [super layoutSubviewDataWithViewModel:viewModel];
    NSDate* now = [NSDate date];
    if (NSOrderedAscending == [now compare:viewModel.sTime]) {
        self.type = CollectTableViewCellTypeGoodsUpComing;
    } else if (NSOrderedDescending == [now compare:viewModel.eTime]) {
        self.type = CollectTableViewCellTypeGoodsIsOut;
    }
}

@end
